<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>scans</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="scanhammer.html" title="scanhammer" />
    <link rel="next" href="scantable.html" title="scantable" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">scans</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="scanhammer.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="scantable.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="scans"></a>
      <div class="titlepage"></div>
      <a id="IndexScans" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">scans</span>
        </h2>
        <p>scans — 
      Generate audio output using scanned synthesis.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp144086016"></a>
        <h2>Description</h2>
        <p>
      Generate audio output using scanned synthesis.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp144087296"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>scans</strong></span> kamp, kfreq, ifn, id [, iorder]</pre>
      </div>
      <div class="refsect1">
        <a id="idp144089456"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn</em></span> -- ftable containing the scanning trajectory.  This is a series of numbers that contains addresses of masses.  The order of these addresses is used as the scan path.  It should not contain values greater than the number of masses, or negative numbers. See the <a class="link" href="SiggenScanTop.html" title="Scanned Synthesis"><em class="citetitle">introduction to the scanned synthesis section</em></a>.
    </p>
        <p>
      <span class="emphasis"><em>id</em></span> -- ID number of the <a class="link" href="scanu.html" title="scanu"><em class="citetitle">scanu</em></a> opcode's waveform to use
    </p>
        <p>
      <span class="emphasis"><em>iorder</em></span> (optional, default=0) -- order of interpolation used internally.  It can take any value in the range 1 to 4, and defaults to 4, which is quartic interpolation.  The setting of 2 is quadratic and 1 is linear.  The higher numbers are slower, but not necessarily better.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp144095552"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp</em></span> -- output amplitude.  Note that the resulting amplitude is also dependent on instantaneous value in the wavetable.  This number is effectively the scaling factor of the wavetable.
    </p>
        <p>
      <span class="emphasis"><em>kfreq</em></span> -- frequency of the scan rate
    </p>
      </div>
      <div class="refsect1">
        <a id="scanexamp"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the scanned synthesis. It uses the file <a class="ulink" href="examples/scans.csd" target="_top"><em class="citetitle">scans.csd</em></a>, and <a class="ulink" href="examples/string-128.matrix" target="_top"><em class="citetitle">string-128.matrix</em></a>.
      </p>
        <div class="example">
          <a id="idp144101632"></a>
          <p class="title">
            <strong>Example 781. Example of the scans opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o scans.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

    <span class="ohdr">sr</span> <span class="op">=</span>   44100
    <span class="ohdr">ksmps</span> <span class="op">=</span>   128
    <span class="ohdr">nchnls</span> <span class="op">=</span>   1

    <span class="oblock">instr</span> 1
a0  <span class="op">=</span> 0
<span class="comment">;   scanu init, irate, ifnvel, ifnmass, ifnstif, ifncentr, ifndamp, kmass, kstif, kcentr, kdamp, ileft, iright, kpos, kstrngth, ain, idisp, id</span>
    <span class="opc">scanu</span> 1,     .01,    6,       2,       3,     4,        5,       2,     .1,    .1,     <span class="op">-</span>.01,  .1,    .5,     0,    0,        a0,  1,     2
<span class="comment">;ar scans kamp,      kfreq,      ifntraj, id</span>
a1  <span class="opc">scans</span> <span class="opc">ampdb</span>(p4), <span class="opc">cpspch</span>(p5), 7,       2
    <span class="opc">out</span> a1
    <span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Initial condition</span>
<span class="stamnt">f</span>1 0 128 7 0 64 1 64 0
   
<span class="comment">; Masses</span>
<span class="stamnt">f</span>2 0 128 -7 1 128 1
   
<span class="comment">; Spring matrices</span>
<span class="stamnt">f</span>3 0 16384 -23 "string-128.matrix"
   
<span class="comment">; Centering force</span>
<span class="stamnt">f</span>4  0 128 -7 0 128 2
   
<span class="comment">; Damping</span>
<span class="stamnt">f</span>5 0 128 -7 1 128 1
   
<span class="comment">; Initial velocity</span>
<span class="stamnt">f</span>6 0 128 -7 0 128 0
   
<span class="comment">; Trajectories</span>
<span class="stamnt">f</span>7 0 128 -5 .001 128 128

<span class="comment">; Note list</span>
<span class="stamnt">i</span>1 0  10  86 6.00
<span class="stamnt">i</span>1 11 14  86 7.00
<span class="stamnt">i</span>1 15 20  86 5.00
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Here is another example of the scanned synthesis, using samples as excitation signal. It uses the file <a class="ulink" href="examples/scans-2.csd" target="_top"><em class="citetitle">scans-2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp144106960"></a>
          <p class="title">
            <strong>Example 782. Second example of the scans opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac   <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o scans-2.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="ohdr">strset</span> 1, "mary.wav"
<span class="ohdr">strset</span> 2, "fox.wav"

<span class="oblock">instr</span> 	2	<span class="comment">;show 2 different trajectories, with samples as excitation signal</span>

ismp <span class="op">=</span> p6		
iamp <span class="op">=</span> p7
itrj <span class="op">=</span> p8
aout <span class="opc">soundin</span> p6				<span class="comment">;choose wave file</span>
     <span class="opc">scanu</span> ismp, .01, 6, 2, 33, 44, 5, 2, .01, .05, <span class="op">-</span>.05, .1, .5, 0, 0, aout, 1, 0
asig <span class="opc">scans</span> iamp, <span class="opc">cpspch</span>(p5), itrj , 0
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>	
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 128 7 0 64 1 64 0			<span class="comment">; Initial condition</span>
<span class="stamnt">f</span>2 0 128 -7 1 128 0.3			<span class="comment">; Masses</span>
<span class="stamnt">f</span>33 0 16384 -23 "cylinder-128,8"	<span class="comment">; Spring matrices</span>
<span class="stamnt">f</span>44 0 128 -7 2 4 0 124 2		<span class="comment">; Centering force</span>
<span class="stamnt">f</span>5 0 128 -7 1 128 0			<span class="comment">; Damping</span>
<span class="stamnt">f</span>6 0 128 -7 -.0 128 0			<span class="comment">; Initial velocity</span>
<span class="stamnt">f</span>7 0 128 -5 .001 128 128		<span class="comment">; Trajectories</span>
<span class="stamnt">f</span>77 0 128 -23 "spiral-8,16,128,2,1over2"

<span class="stamnt">s</span>
<span class="stamnt">i</span>2 0  5  63 6.00 1 .9 7			<span class="comment">;"mary.wav" &amp;</span>
<span class="stamnt">i</span>2 6  5  60 7.00			<span class="comment">;trajectory table 7</span>
<span class="stamnt">i</span>2 10 5  60 8.00

<span class="stamnt">s</span>
<span class="stamnt">i</span>2 0  5  63 6.00 2 .08 7		<span class="comment">;"fox.wav", at much lower volume</span>
<span class="stamnt">i</span>2 6  5  60 7.00
<span class="stamnt">i</span>2 10 5  60 8.00

<span class="stamnt">s</span>
<span class="stamnt">i</span>2 0  5  63 6.00 1 .9 77		<span class="comment">;"mary.wav" &amp;</span>
<span class="stamnt">i</span>2 6  5  60 7.00			<span class="comment">;trajectory table 77</span>
<span class="stamnt">i</span>2 10 5  60 8.00

<span class="stamnt">s</span>
<span class="stamnt">i</span>2 0  5  63 6.00 2 .08 77		<span class="comment">;"fox.wav", at much lower volume</span>
<span class="stamnt">i</span>2 6  5  60 7.00
<span class="stamnt">i</span>2 10 5  60 8.00
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp144108928"></a>
        <h2>See Also</h2>
        <p>
      The matrix file <span class="quote">“<span class="quote">string-128.matrix</span>”</span>, as well as several other matrices, is also available in a <a class="ulink" href="http://www.csounds.com/scanned/zip/scanmatrices.zip" target="_top"><em class="citetitle">zipped file</em></a> from the <a class="ulink" href="http://www.csounds.com/scanned/" target="_top"><em class="citetitle">Scanned Synthesis page</em></a> at cSounds.com.
    </p>
        <p> More information on this opcode: <a class="ulink" href="http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html" target="_top"><em class="citetitle">http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html</em></a>  , written by Steven Yi </p>
      </div>
      <div class="refsect1">
        <a id="idp144113808"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Paris Smaragdis</td>
          </tr>
          <tr>
            <td>MIT Media Lab</td>
          </tr>
          <tr>
            <td>Boston, Massachussetts USA</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 4.05</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="scanhammer.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="scantable.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">scanhammer </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> scantable</td>
        </tr>
      </table>
    </div>
  </body>
</html>
